package com.cj.minio.config;

import io.minio.MinioClient;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * minio配置
 *
 * @author Mjg
 * @QQ:2091864671
 * @Create by mjg ON 2021/5/21-15:09
 * @date 2021/05/21
 */
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {

    private String endpoint;

    private String accessKey;

    private String secretKey;

    /**
     * 如果是true，则用的是https而不是http,默认值是true"
     */
    private Boolean secure;


    /**
     * 默认存储桶
     */
    private String bucketName;

    @Bean("minioClient")
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

}
